#include<bits/stdc++.h>
#define ll long long
#define Max(a,b,c)  max(a,max(b,c))
#define inf 2100000000
#define fa(i,n,k) for(register int i=k;i<=n;i++)

using namespace std;
int n,l,r,maxn;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&l,&r);
	for(register int i=l;i<=r;i++)
		maxn=max(i%n,maxn);
	cout<<maxn;
	return 0;
}

